Skip to content

fix(init): warn when jq is missing during hook installation#864

Open
blpsoares wants to merge 1 commit intortk-ai:developfrom
blpsoares:fix/init-check-jq-dependency
Open

fix(init): warn when jq is missing during hook installation#864
blpsoares wants to merge 1 commit intortk-ai:developfrom
blpsoares:fix/init-check-jq-dependency

Conversation

@blpsoares
Copy link

Summary

  • Add a soft check during rtk init -g (and Cursor hook installation) that warns when jq is not found on PATH
  • Prints install instructions for macOS, Ubuntu, Fedora, Arch, and a link for other platforms
  • Add a test to verify the check never panics regardless of jq availability

Problem

The shell-based hook (rtk-rewrite.sh) requires jq to parse the JSON payload from Claude Code. When jq is not installed, the hook exits silently (exit 0, no output), causing every command to fall through without RTK rewriting — resulting in zero token savings with no visible error.

This is particularly frustrating because rtk init -g reports success, rtk gain shows the hook is "configured", but nothing actually works. The user can spend hours in a Claude Code session with no savings and no indication of what's wrong.

Approach

This is intentionally a minimal, non-breaking fix:

  • Soft warning only (does not fail init)
  • Runs after hook installation so the rest of setup completes normally
  • Applies to both Claude Code and Cursor hook paths

This is a stopgap until #785 lands, which eliminates the jq dependency entirely by replacing the shell hook with a native rtk hook claude subcommand.

Test plan

  • Run rtk init -g with jq installed — no warning shown
  • Run rtk init -g without jq installed — warning with install instructions shown
  • cargo test init::tests::test_check_jq_available_does_not_panic passes
  • cargo clippy --all-targets — no new warnings

🤖 Generated with Claude Code

@CLAassistant
Copy link

CLAassistant commented Mar 26, 2026

CLA assistant check
All committers have signed the CLA.

@blpsoares blpsoares changed the base branch from master to develop March 26, 2026 15:45
@blpsoares blpsoares force-pushed the fix/init-check-jq-dependency branch from b363c2d to 4bea219 Compare March 26, 2026 15:47
@aeppling
Copy link
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

The shell-based hook (rtk-rewrite.sh) requires jq to parse JSON from
Claude Code / Cursor. When jq is not installed the hook exits silently
(exit 0, no output), causing every command to fall through without RTK
rewriting — resulting in zero token savings with no visible error.

Add a soft check during `rtk init -g` that warns the user if jq is not
found on PATH, with install instructions for common platforms.

This is a stopgap until the hook is replaced by a native Rust subcommand
(see rtk-ai#785).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@blpsoares blpsoares force-pushed the fix/init-check-jq-dependency branch from 4bea219 to ce418d9 Compare March 26, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants